// @ts-ignore
import { createWebHashHistory, createRouter } from 'vue-router';
// @ts-ignore
import type { RouteRecordRaw } from 'vue-router';

// 定义静态路由
// 登录、注册、首页、找不到的页面
const frontendRoutes: RouteRecordRaw[] = [
    {
        path: '/:catchAll(.*)', // 404 页面
        component: () => import("@/components/FrontendNotFound.vue"),
        meta: { authorityName: "找不到了" }
    },

    {
        path: '/homeview/sicuan',
        name: "Sicuan",
        component: () => import("@/user-view/sicuan/Sicuan.vue")
    },
    {
        path: '/register',
        name: "Register",
        component: () => import("@/views/Register.vue"),
        meta: {
            authorityName: "注册",
            hideNavBar: true
        }
    },
    {
        path: '/play/:resourceId/:resourceType',
        name: "player",
        component: () => import("@/views/resource/Player.vue"),
        props: true,
        meta: {
            authorityName: "播放页面"
        }
    },
    {
        path: '/redirect/:originalPath(.*)',
        component: () => import("@/components/RedirectSelf.vue")
    },
    {
        path: '/homeview',
        name: "HomeView",
        component: () => import("@/user-view/HomeView.vue")
    },
    {
        path: '/arts',
        name: "Arts",
        component: () => import("@/views/Physical-Education/Arts Skills.vue")
    },
    {
        path: '/sports',
        name: "Sports",
        component: () => import("@/views/Physical-Education/Sports Skills.vue")
    },
    {
        path: '/labor',
        name: "Labor",
        component: () => import("@/views/labor/Labor-main.vue"),
    },
    {
        path: '/afterschool',
        name: "AfterSchool",
        component: () => import("@/views/after-school/after-school-main.vue"),
    },
    {
        path: '/recommended',
        name: "recommended",
        component: () => import("@/user-view/Recommended/Recommended.vue"),
        children: [
            {
                path: '/recommended/bestCourses',
                name: "BestCourses",
                component: () => import("@/user-view/recommended/bestCourses.vue")
            }
        ]
    },
    {
        path: '/recommended/bestCourses',
        name: "BestCourses",
        component: () => import("@/user-view/recommended/bestCourses.vue")
    },
    {
        path: '/usercenter',
        name: "UserCenter",
        component: () => import("@/user-view/UserCenter/UserCenter.vue"),
        children: [
            {
                path: '/usercenter/userprofile',
                component: () => import("@/user-view/UserCenter/UserProfile.vue")
            },
            {
                path: '/usercenter/likecenter',
                component: () => import("@/user-view/UserCenter/LikeCenter.vue")
            },
            {
                path: '/usercenter/favoritescenter',
                component: () => import("@/user-view/UserCenter/FavoritesCenter.vue")
            },{
                path: '/usercenter/historycenter',
                component: () => import("@/user-view/UserCenter/historyCenter.vue")
            },
        ]
    },
    {
        path: '/chat',
        name: "chat",
        component: () => import("@/user-view/UserCenter/chat/ChatWindow.vue")
    },
    {
        path: '/moral',
        name: "Moral",
        component: () => import("@/user-view/moral/Moral.vue")
    },
    {
        path: '/course',
        name: 'Course',
        component: () => import('@/user-view/course/Course.vue'),
        children: [
            {
                path: 'studentCourses',
                name: 'StudentLearning',
                component: () => import('@/user-view/course/StudentLearning.vue')
            },
            {
                path: 'teacherCourses',
                name: 'TeacherPreparation',
                component: () => import('@/user-view/course/TeacherPreparation.vue')
            },
            {
                path: 'premiumCourse',
                name: 'PremiumCourse',
                component: () => import('@/user-view/course/teacher/PremiumCourse.vue')
            },
            {
                path: 'experimentalTeaching',
                name: 'ExperimentalTeaching',
                component: () => import('@/user-view/course/teacher/ExperimentalTeaching.vue')
            },
            {
                path: 'basicAssignment',
                name: 'BasicAssignment',
                component: () => import('@/user-view/course/teacher/BasicAssignment.vue')
            },
            {
                path: 'exerciseBank',
                name: 'ExerciseBank',
                component: () => import('@/user-view/course/teacher/ExerciseBank.vue')
            }
        ]
    },
    {
        path: '/course/new-premium',
        name: 'PremiumCourse',
        component: () => import('@/user-view/course/teacher/PremiumCourse.vue')
    },
    {
        path: '/search',
        name: 'Search',
        component: () => import('@/user-view/Search.vue')
    }
];

const staticRoutes: RouteRecordRaw[] = [
    {
        path: '/login',
        name: "Login",
        component: () => import("@/views/Login.vue"),
        meta: {
            authorityName: "登录",
            hideNavBar: true
        }
    },
    {
        path: '/register',
        name: "Register",
        component: () => import("@/views/Register.vue"),
        meta: {
            authorityName: "注册",
            hideNavBar: true
        }
    },
    {
        path: '/',
        name: "Layout",
        component: () => import("@/views/Layout.vue"),
        children: [],
        meta: {
            authorityName: "首页",
            hideNavBar: true
        }
    }
];

const router = createRouter({
    history: createWebHashHistory(),
    routes: [...staticRoutes, ...frontendRoutes]
});

export default router;
